<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAnswerSheetTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('answer_sheet', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('activity_id')->default(0)->comment('活动id');
            $table->string('title')->nullable()->comment('标题');
            $table->string('desc')->nullable()->comment('描述');
            $table->integer('total_score')->default(0)->comment('总分数');
            $table->integer('sort')->default(1)->comment('答案批次');
            $table->timestamp('start_time')->nullable()->comment('答题开始时间');
            $table->timestamp('end_time')->nullable()->comment('答题结束时间');
            $table->integer('is_score')->default(0)->comment('是否评分 0：未评分 1：已评分');
            $table->integer('status')->default(0)->comment('状态');
            $table->softDeletes();
            $table->timestamps();
        });

        Schema::create('questions', function(Blueprint $table)
        {
            $table->increments('id')->comment('用户标识');
            $table->integer('as_id')->default(0)->comment('答卷id');
            $table->string('questions')->nullable()->comment('题目');
            $table->text('answer')->nullable()->comment('答案');
            $table->string('desc')->nullable()->comment('题目描述');
            $table->integer('score')->default(0)->comment('分数');
            $table->integer('type')->default(0)->comment('类型');
            $table->integer('sort')->default(0)->comment('状态');
            $table->integer('status')->default(0)->comment('状态');
            $table->softDeletes();
            $table->timestamps();
        });

        Schema::create('user_answer', function(Blueprint $table)
        {
            $table->increments('id')->comment('用户标识');
            $table->integer('user_id')->default(0)->comment('用户id');
            $table->integer('as_id')->default(0)->comment('答卷id');
            $table->integer('score')->default(0)->comment('分数');
            $table->timestamp('submit_time')->nullable()->comment('提交时间');
            $table->integer('status')->default(0)->comment('状态 0：去回答 1：评分中 2：已评分');
            $table->softDeletes();
            $table->timestamps();
        });

        Schema::create('user_answer_detail', function(Blueprint $table)
        {
            $table->increments('id')->comment('用户标识');
            $table->integer('ua_id')->default(0)->comment('答题情况id');
            $table->string('q_id')->nullable()->comment('题目');
            $table->text('answer')->nullable()->comment('答案');
            $table->integer('score')->default(0)->comment('分数');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
